Skip to content

feat: instant launch — explicit failure UX in the loading page - #149

Merged
zackees merged 1 commit into
mainfrom
feat/instant-launch
Jun 7, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/instant-launch

Conversation

@zackees

@zackees zackees commented Jun 7, 2026

Copy link
Copy Markdown
Member

Closes #148.

Summary

The instant-launch flow is already in place: commands.rs::compile_and_serve starts the HTTP server, spawns the Tauri viewer, and only then runs the first compile — so the viewer window opens within ~1s and serves LOADING_PAGE (which streams /build-stream SSE) while compilation happens behind it. On success, the page reloads to fetch the freshly-written index.html. This PR closes the remaining acceptance-criteria gaps in #148 by hardening the page's behavior on compile failures and on rebuilds.

Changes (all in crates/fastled-cli/src/server.rs)

  • Explicit failure UX. Previously a failed compile only updated the status text; the spinner kept spinning indefinitely. Now setError() switches the spinner to red, stops the elapsed timer, and explicitly keeps the page on the build view — no navigation, no 404 (criterion 5).
  • Elapsed time counter. New #elapsed shows tenths-of-a-second beside the status. Useful on cold-cache first compiles (criterion 3).
  • Log clearing on rebuild. When a fresh compiling status arrives after a prior build, the log is cleared and the timer reset, so the user sees the new compile's output cleanly. Without this, a second failure would visually stack on top of the first (criterion 6).
  • Cleanup. Removed a dead const logEl = document.addEventListener(...) binding that only captured undefined.

Test

New test_loading_page_stays_when_build_failed_and_no_index_html:

  • Seeds the server's output dir with a build-status.json of status=error.
  • Verifies GET / still returns 200 with the loading page (never 404, never a stale page).
  • Asserts the embedded setError branch is present in the served HTML.

Out of scope

  • Handling rebuild-failure once the viewer has already transitioned to the running sketch (the sketch page doesn't currently subscribe to SSE — that would require frontend-side wiring in src/fastled/frontend/).
  • Changing the viewer-launch order in commands.rs (it's already correct).

Test plan

  • soldr cargo test -p fastled-cli --lib server:: -> 18/18 pass
  • CI on this PR (clippy / fmt / dylint not run locally due to a stuck zccache daemon on this workstation)
  • Manual smoke: launch fastled <sketch>, observe viewer opens immediately with streaming log; introduce a syntax error and verify viewer stays on build view with red spinner; fix it, verify next rebuild clears log and transitions to sketch.

The instant-launch flow already exists: compile_and_serve starts the
HTTP server, spawns the Tauri viewer, and only then runs the first
compile — so the viewer opens within ~1s and serves LOADING_PAGE
(which streams /build-stream SSE) while compilation happens behind it.
On success, the page reloads to fetch the freshly-written index.html.

This PR closes the remaining acceptance-criteria gaps in #148:

  * Error UX: previously a failed compile only updated the status text
    while the spinner kept spinning. Now setError() switches the spinner
    to red, stops the elapsed timer, and explicitly keeps the page on
    the build view (no navigation, no 404).
  * Elapsed time: new #elapsed counter alongside the status, useful on
    cold-cache first compiles.
  * Log clearing on rebuild: when a fresh 'compiling' status arrives
    after a prior build, the log is cleared and the timer reset so the
    user sees the new compile's output cleanly. Without this, a second
    failure would stack on top of the first.
  * Cleanup: removed a dead `const logEl = document.addEventListener(...)`
    binding that only captured undefined.

New test test_loading_page_stays_when_build_failed_and_no_index_html
seeds the server's output dir with a build-status.json of status=error
and verifies GET / still returns 200 with the loading page (asserts the
embedded setError branch is present).

Verified: `soldr cargo test -p fastled-cli --lib server::` → 18 passed.

Closes #148

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: instant launch — open web view immediately, stream compile, switch to sketch when ready

1 participant